package org.odk.clinic.android.activities;

import org.odk.clinic.android.R;
import org.odk.clinic.android.database.SQLiteAdapter;


import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class ViewEncounterActivity extends ListActivity{
	SQLiteAdapter mDB;
	Cursor mCursor;
	protected void onCreate(Bundle ici){
		super.onCreate(ici);
	 setContentView(R.layout.list_encounter);
	 
	 mDB = new SQLiteAdapter(this);
	 mDB.open();
	 
	 int mid = DetailPatientActivity.mid;
	 mCursor = mDB.getAllEncounter(mid);
	 //mCursor = mDB.getAllEncounter(1);
	 if(mCursor.moveToFirst()){
		 do{
			 	startManagingCursor(mCursor);
			    String[] from = new String[]{SQLiteAdapter.KEY_ENCOUNTER_DATE,SQLiteAdapter.KEY_ENCOUNTERNAME,SQLiteAdapter.KEY_PATIENT_ID};
				int[] to = new int[]{R.id.en_date,R.id.en_type,R.id.en_location};
				SimpleCursorAdapter per = new SimpleCursorAdapter(this,R.layout.list_encounter_item,mCursor,from,to);
				setListAdapter(per);
		 }
		 while (mCursor.moveToNext());
	 }
	 
	 
	}

}
